package com.hengxinguotong.hxgtwygsp.utils;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

/**
 * Created by hjz on 2018/6/14.
 */

public class ToastUtils
{
    private static Toast sSimpleToast;
    private static Toast sImageToast;

    public static void showSimpleToast(Context context, String content)
    {
        if (sSimpleToast == null)
        {
            sSimpleToast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
        } else
        {
            sSimpleToast.setText(content);
        }
        sSimpleToast.show();
    }

    public static void showSimpleToast(Context context, int contentId)
    {
        if (sSimpleToast == null)
        {
            sSimpleToast = Toast.makeText(context, contentId, Toast.LENGTH_SHORT);
        } else
        {
            sSimpleToast.setText(contentId);
        }
        sSimpleToast.show();
    }

    public static void showImageToast(Context context, View view)
    {
        if (sImageToast == null)
        {
            sImageToast = new Toast(context);
            sImageToast.setGravity(Gravity.CENTER, 0, 0);
            sImageToast.setView(view);
            sImageToast.setDuration(Toast.LENGTH_LONG);
        } else
        {
            sImageToast.setView(view);
        }

        sImageToast.show();
    }
}
